#ifndef QUEUE_H
#define QUEUE_H

#define QUEUE_SIZE  10

struct Queue {
  float _q[QUEUE_SIZE];
  int _size;
  int head;
  int tail;
  Queue() {
    _size = head = tail = 0;
  }
  
  int size() { 
    return _size;
  }
  ;
  int empty() {
    return this->size() == 0 ? 1 : 0;
  }

  int top() {
    if (!this->empty()) {
      return _q[head];
    }
    return 0;
  }

  void push_back(int ele) {
    if (_size == QUEUE_SIZE) {
      this->pop_front();
    }
    _q[tail++] = ele;
    tail = tail % QUEUE_SIZE;
    _size++;
  }

  void pop_front() {
    if (!this->empty())  {
      head++;
      head = head % QUEUE_SIZE;
      _size--;
    }
  }

  void clear() {
    _size = head = tail = 0;  
  }
};

typedef struct Queue Queue;

#endif
